﻿/*
This file is used specifically for header menu
*/
                var hoverBackgroundColor = "";
                var hoverTextColor = "ffffff";
				
                
                function findPos(obj) 
                {
	                var curleft = curtop = 0;
	                if (obj.offsetParent) {
		                curleft = obj.offsetLeft
		                curtop = obj.offsetTop
		                while (obj = obj.offsetParent) {
			                curleft += obj.offsetLeft
			                curtop += obj.offsetTop
		                }
	                }
	                return [curleft,curtop];
                }

                function fnDisplayMenu(parent, mnuName)
                {
	                var mnuElem = document.getElementById(mnuName);
	                mnuElem.style.display = "block";
	                //mnuElem.style.top = fnGetMenuTopPosition();
	                if (mnuName == "mnuArtStyles" || mnuName == "mnuArtists")
	                {
	                    var placement = findPos(parent);
	                    mnuElem.style.left = placement[0] + "px";
	                }
	                fnHighlightTD(mnuName);
					try
					{
					fnChangeMenuSeparatorColor(mnuName, "hidden");
					}catch(e){}
                }

                function fnHideMenu(mnuName)
                {
	                var mnuElem = document.getElementById(mnuName);
	                mnuElem.style.display = "none";
					try
					{
	                fnChangeMenuSeparatorColor(mnuName, "visible");
					}catch(e){}
                }

                function fnHighlightTD(mnuName)
                {
					
                    var elem = document.getElementById(mnuName + "Link");
					
                    elem.style.backgroundColor = hoverBackgroundColor;
                    elem.style.color = hoverTextColor;
                }

                function fnRemoveHighlight(mnuName)
                {
                    var elem = document.getElementById(mnuName + "Link");
                    elem.style.backgroundColor ='';// hoverBackgroundColor;
                   elem.style.color = "ffffff"; //hoverBackgroundColor;
					//alert(1)
                }

                function fnChangeMenuSeparatorColor(mnuName, disp)
                {
					
                    var spanDivider1 = document.getElementById("divider1");
                    var spanDivider2 = document.getElementById("divider2");
                    var spanDivider3 = document.getElementById("divider3");
                    var spanDivider4 = document.getElementById("divider4");
                    var spanDivider5 = document.getElementById("divider5");
                    switch(mnuName)
	                {
	                    case "mnuArtStyles":
	                    {
	                        spanDivider1.style.visibility = disp;
	                        break;
	                    }
	                    case "mnuSubjects":
	                    {
	                        spanDivider1.style.visibility = disp;
	                        spanDivider2.style.visibility = disp;
	                        break;
	                    }
	                    case "mnuArtists":
	                    {
	                        spanDivider2.style.visibility = disp;
	                        spanDivider3.style.visibility = disp;
	                        break;
	                    }
	                    case "mnuProductTypes":
	                    {
	                        spanDivider3.style.visibility = disp;
	                        spanDivider4.style.visibility = disp;
	                        break;
	                    }
	                    case "mnuCollections":
	                    {
	                        spanDivider4.style.visibility = disp;
	                        spanDivider5.style.visibility = disp;
	                        break;
	                    }
	                }
                }

                function fnUnderlineLink(linkElem)
                {
                    linkElem.style.textDecoration = "underline";
                    linkElem.style.cursor = "pointer";
                }

                function fnRemoveUnderline(linkElem)
                {
                    linkElem.style.textDecoration = "none";
                    linkElem.style.cursor = "arrow";
                }

                function fnGetMenuTopPosition()
                {
                    // Code to get the CSToolbar
                    var csToolbar = document.getElementById("CSContainer");
                    //alert(csToolbar);
                    var csToolbarHeight = 0;
                    if (csToolbar)
                    {
                        if (csToolbar.style.display != "none")
                        {
                            csToolbarHeight = csToolbar.offsetHeight
                        }
                    }
                    //var csToolbarHeight = 0;
                    var artLogoSpace = document.getElementById("HeaderRight");
                    var headerMenuDiv = document.getElementById("HeaderBar");
                    var popMenuTop = parseInt(csToolbarHeight) + parseInt(headerMenuDiv.offsetHeight) + parseInt(artLogoSpace.offsetHeight);
                    return popMenuTop;
                }

                window.onload=function()
                {
                    fnSetTopPosForHeaderMenu();
                }

                function fnSetTopPosForHeaderMenu()
                {
                    var popMenuTop = fnGetMenuTopPosition();

                    var menu = document.getElementById("mnuArtStyles");
                    menu.style.Top = popMenuTop;

                    menu = document.getElementById("mnuSubjects");
                    menu.style.Top =  popMenuTop;

                    menu = document.getElementById("mnuArtists");
                    menu.style.Top =  popMenuTop;

                    menu = document.getElementById("mnuProductTypes");
                    menu.style.Top =  popMenuTop;

                    menu = document.getElementById("mnuCollections");
                    menu.style.Top =  popMenuTop;
                }
